package com.awn.weidian.demo.controller;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import com.awn.weidian.demo.mapper.IGoodsClass;
import com.awn.weidian.demo.pojo.GoodsClass;
import com.awn.weidian.demo.service.DateHandle;
import com.awn.weidian.demo.service.TreeHandle;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@CrossOrigin
@RequestMapping("/api/")

public class GoodsClassController {
    
	@Autowired
    IGoodsClass dm;

    @Autowired
    TreeHandle th;

    @GetMapping("/showgc")
    public List<Map<String,Object>> showAll(){
		return th.findRows(-1,dm.showAll());
    }


	@PostMapping("/addgc")
    public int addAll(@RequestBody GoodsClass goodClass){
        return dm.addAll(goodClass);
    }

      @PutMapping("/findcid/{aa}")
    public GoodsClass findcid(@PathVariable String aa){
        return dm.findcid(aa);
    }

    @DeleteMapping("/delgc/{cid}")
    public int delAll(@PathVariable int cid){
        return dm.delAll(cid);
    }

    @PostMapping("/updategc")
    public int updateAll(@RequestBody GoodsClass goodClass){
        return dm.updateAll(goodClass);
    }

    

}
